package com.baitengsoft.patentapimonitor.common.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.ResourceUtils;
import sun.rmi.runtime.Log;

import java.io.*;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;

/**
 * Created by Admin on 2017/12/28.
 */
public class TemplateFileUtil {
    private final static Logger LOG = LoggerFactory.getLogger(TemplateFileUtil.class.getName());


    public static InputStream getTemplates(String tempName) {
        return TemplateFileUtil.class.getResourceAsStream("/excel-templates/" + tempName);
    }


    public static ResourceBundle getBundle(String name) {
        try (InputStream stream = new BufferedInputStream(TemplateFileUtil.class.getClassLoader().getResourceAsStream(name + ".Properties"))) {
            return new PropertyResourceBundle(stream);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }


}
